package com.example.boot.test.services;

import com.example.boot.test.mapper.DemoMapper;
import com.example.boot.test.model.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author ruiwu
 * @version V1.0
 * @Description:
 */
@Service
public class DemoService {

    @Autowired
    private DemoMapper demoMapper;
    public List<Account> findAllAccount() {
        return demoMapper.findAllAccount();
    }
    //测试声明事务
    @Transactional
    public void testTransactional() {
        demoMapper.testTransactional(990,1); //用户1减10块 用户2加10块
        int i=1/0;
        demoMapper.testTransactional(1100,2);
    }
}
